package com.kwok.openplatform.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kwok.openplatform.dao.CustomerDao;
import com.kwok.openplatform.entity.Customer;
import com.kwok.openplatform.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 客户表(Customer)表服务实现类
 *
 * @author Kwok
 * @since 2024-07-21 18:31:38
 */
@Service
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    private CustomerDao customerDao;

    @Override
    public Customer queryCustomerById(Integer customerId) {
        return customerDao.selectCustomerById(customerId);
    }

    @Override
    public PageInfo<Customer> queryCustomers(Integer page,Integer limit,Customer customer) {
        //PageHelper.startPage(1,4);
        PageHelper.startPage(page,limit);
        List<Customer> list = customerDao.selectCustomers(customer);
        PageInfo<Customer> pageInfo = new PageInfo<Customer>(list);
        return pageInfo;
    }

    @Override
    public List<Customer> queryCustomerList() {
        return customerDao.selectCustomerList();
    }

    @Override
    public Integer saveCustomer(Customer customer) {
        return customerDao.insertCustomer(customer);
    }

    @Override
    public Integer updateCustomerById(Customer customer) {
        return customerDao.updateCustomerById(customer);
    }

    @Override
    public Integer removeCustomerById(Integer id) {
        return customerDao.deleteCustomerById(id);
    }

    @Override
    public Integer batchRemoveCustomerById(Integer... ids) {
        return customerDao.batchDeleteCustomerById(ids);
    }

}

